<?php
namespace Home\Controller;
use Think\Controller;
class InitController extends Controller
{
    public function index()
    {
        $this->display();
    }
    public function init()
    {
        $share=D('Share');
        $beginCode=$_POST["beginCode"];
        $endCode=$_POST["endCode"];
        
        //测试数据
        //$beginCode="000001";
        //$endCode="000010";
   
        /*检验数值是否正确 需要再写，这个有问题
        if(preg_match("^[0-9]{6}$",$beginCode)==false)
        {
            echo "-1";
        
        }
        if(preg_match('[0-9]{6}',$endCode)==false)
        {
            echo "-2";
            
        }
        echo "3";
        */
        set_time_limit(0);
        for($i=$beginCode;$i<=$endCode;)
        {
            $count=str_pad($i,6,0,STR_PAD_LEFT);
            $share::initShare($count);
            $i=str_pad($i+1,6,0,STR_PAD_LEFT);
        }
        $data = 'ok';
        $this->ajaxReturn($data);
        
        
    }
}